import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/views/layout/index.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "主页",
      component: Layout,
      redirect: "/dashBoard",
      children: [
        {
          path: "/dashBoard",
          name: "仪表盘",
          component: () => import("@/views/dashBoard/index.vue"),
        },
        {
          path: "/goods",
          name: "商品",
          redirect: "/goods/list",
          children: [
            {
              path: "list",
              name: "商品列表",
              component: () =>
                import("@/views/goodsManage/goodsList/index.vue"),
            },
            {
              path: "sort",
              name: "商品分类",
              component: () =>
                import("@/views/goodsManage/goodsSort/index.vue"),
            },
            {
              path: "addGoods",
              name: "添加商品",
              component: () => import("@/views/goodsManage/goodsAdd/index.vue"),
            },
          ],
        },
        {
          path: "/permission",
          name: "权限管理",
          component: () => import("@/views/permission/index.vue"),
        },
        {
          path: "/userInfo",
          name: "个人中心",
          component: () => import("@/views/userInfo/index.vue"),
        },
      ],
    },
    {
      path: "/:pathMatch(.*)*",
      name: "NotFound",
      component: () => import("@/views/notFound/index.vue"),
    },
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/login/index.vue"),
    },
  ],
});

export default router;
